<?php
set_time_limit(0);
$servername = "localhost";
$username = "root";
$password = "root";
 
if(file_exists("D:/webulfile.txt")){
	unlink ( 'D:/webulfile.txt' );
}

// 创建连接
$conn = new mysqli($servername, $username, $password);
 
// 检测连接
if ($conn->connect_error) {
    die("数据库连接失败: " . $conn->connect_error);
}



mysqli_select_db( $conn, 'web_download' );

$result = mysqli_query($conn,"SELECT * FROM download_data2");
// echo "正在查询数据库..."."<br>"."<br>";
while ( $getArray = mysqli_fetch_array($result,MYSQLI_ASSOC) ) {
	$PN[] = $getArray['webdl_pn'];
	$WSID[] = $getArray['webdl_wsid'];
	$TPVER[] = $getArray['webdl_tpver'];
	$WO[] = $getArray['webdl_work_order'];
	$CREATOR[] = $getArray['webdl_creator'];
	$IP[] = $getArray['webdl_ftpip'];
	$CTIME[] = $getArray['webdl_create_date'];
	$DCOUNT[] = $getArray['webdl_count'];
	// echo "<pre>";
	// print_r($getArray);
}

$conn->close();
$IP_num = count($IP);
echo '数据库总笔数： '.$IP_num."<br>"."<br>";
$myfile = fopen("D:/webulfile.txt", "a") or die("Unable to open file!");
for ($i=0; $i <$IP_num ; $i++) { 
	if(@!file_exists($IP[$i])){							
		$c="\r\n$WO[$i]  $PN[$i]  $WSID[$i]  $TPVER[$i]  $CREATOR[$i]  $CTIME[$i]  $DCOUNT[$i]                  $IP[$i]";
		fwrite($myfile, $c);		
	}
}
fclose($myfile);//关闭该操作
echo "搜索完成";
?>